<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>插值语法</title>
  <script src="../../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <div>用户名: {{uname}}</div>
    <div>年龄: {{age}}</div>
    <div>后年年龄: {{age+2}}</div>
    <div>成年了吗: {{age>=18}}</div>
    <div>成年了吗: {{age>=18? "成年": "未成年"}}</div>
    <div>是否在工作年龄: {{age>=18 && age<=60}}</div>
    <div>用户名长度: {{uname.length}}</div>
    <div>用户名大写: {{uname.toUpperCase()}}</div>
    <div>用户名下标为2的字符: {{uname[2]}}</div>
    <div>json: {{obj}}</div>
    <div>调用全局函数: {{add()}}</div>
    <div>匿名自调用函数: {{ (function(){ return 100 + 100 })() }}</div>
  </div>
  <script>
    let data = {
      uname: "李逍遥",
      age: 18,
      obj: { salary: 5000 }
    }

    new Vue({
      el: "#app",
      data, //data: data,
      methods: {
        add() {
          return this.uname
        }
      }
    });
  </script>
</body>

</html>